package com.wyl.xue.core.util;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;

public enum UserTools {
    tools;

    public String getUserNameByRequest() {
        UserDetails systemUsers = (UserDetails) SecurityContextHolder.getContext()
                                                                     .getAuthentication()
                                                                     .getPrincipal();
        return systemUsers.getUsername();
    }

    public UserDetails getUserInfoByRequest() {
        return (UserDetails) SecurityContextHolder.getContext()
                                                  .getAuthentication()
                                                  .getPrincipal();
    }
}
